package com.ekuaitu.kuaitu.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.ekuaitu.kuaitu.R;
import com.ekuaitu.kuaitu.base.BaseActivity;
import com.ekuaitu.kuaitu.utils.AppManager;
import com.ekuaitu.kuaitu.utils.Constants;
import com.ekuaitu.kuaitu.utils.StatusBarUtil;
import com.ekuaitu.kuaitu.utils.Toast.ToastCompat;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ChangeNameActivity extends BaseActivity {

    @BindView(R.id.return_changeName)
    ImageView returnChangeName;
    @BindView(R.id.save)
    TextView save;
    @BindView(R.id.toolbar_changeName)
    AutoRelativeLayout toolbarChangeName;
    @BindView(R.id.changeName)
    EditText changeName;
    @BindView(R.id.changeName_pb)
    ProgressBar changeNamePb;


    @Override
    public int getLayoutId() {
        return R.layout.activity_change_name;
    }

    @Override
    public void initView() {
        StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimaryWhite), 0,true);

        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        changeName.setText(name);
    }

    @OnClick({R.id.return_changeName, R.id.save})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.return_changeName:
                finish();
                break;
            case R.id.save:
                if (!TextUtils.isEmpty(changeName.getText().toString())) {
                    Intent intent1 = new Intent();
                    intent1.putExtra("name", changeName.getText().toString());
                    setResult(Constants.REQUEST_CHANGE_INFO, intent1);
                    finish();
                } else {
                    ToastCompat.makeText(this, "请输入昵称！", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}
